<%@page import="org.book.service.BookService"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.book.dao.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<%-- 静态包含 base标签、css样式、jQuery文件 --%>
		<%@ include file="/pages/common/head.jsp"%>


		<script type="text/javascript">
			// 页面加载完成之后
			$(function () {
				// 给注册绑定单击事件
				$("#sub_btn").click(function () {
					//1 获取用户名输入框里的内容
					var usernameText = $("#username").val();
					if (usernameText ==null || usernameText == "") {
						//4 提示用户
						$("span.errorMsg").text("图书编号不能为空！");

						return false;
					}

					var passwordText = $("#password").val();
					if (passwordText ==null || passwordText == "") {
						//4 提示用户
						$("span.errorMsg").text("图书名称不能为空！");

						return false;
					}

					var repwdText = $("#repwd").val();
					if (repwdText ==null || repwdText == "") {
						//4 提示用户
						$("span.errorMsg").text("价格不能为空！");

						return false;
					}
					var emailText = $("#email").val();
					if (emailText ==null || emailText == "") {
						//4 提示用户
						$("span.errorMsg").text("出版社不能为空！");

						return false;
					}
					var codeText = $("#code").val();


					if (codeText ==null || codeText == "") {
						//4 提示用户
						$("span.errorMsg").text("作者不能为空！");

						return false;
					}

					// 去掉错误信息
					$("span.errorMsg").text("");

				});

			});

		</script>
	<style type="text/css">
		.login_form{
			height:420px;
			margin-top: 25px;
		}
		</style>
</head>
<body>
	<%
		//保持页码
		String pageCurrent2 = request.getParameter("pageCurrent2");
		String no = request.getParameter("no");
		if(no==null||pageCurrent2==null){
			request.getRequestDispatcher("../../index.jsp").forward(request, response);
			return;
		}
		int id = -1;
		String ISBN = "";
		String bookName = "";
		String price = "";
		String press = "";
		String author = "";
		String str1 = "图书添加";
		String str2 = "输入添加信息";
		//修改
		if(no!=null){
			id = Integer.parseInt(no);
			BookService bookService = new BookService();
			BookBean stu = bookService.getStuByNo(id);
			ISBN = stu.getISBN();
			bookName = stu.getBookName();
			price = stu.getPrice()+"";
			press = stu.getPress();
			author = stu.getAuthor();
			
			
			str1 = "图书修改";
			str2 = "输入修改信息";
		}
		
	%>
	
	
	<div id="login_header">
			<img class="logo_img" alt="" src="static/img/logo.gif" >
		</div>

			<div class="login_banner">

				<div id="l_content">
					<span class="login_word"><%=str1 %></span>
				</div>

				<div id="content">
					<div class="login_form">
						<div class="login_box">
							<div class="tit">
								<h1><%=str2 %></h1>
								<span class="errorMsg">
									${ requestScope.msg }
								</span>
							</div>
							<div class="form">
								<form action="BookUpdateServlet?no=<%=id %>&pageCurrent2=<%=pageCurrent2 %>" method="post">
									<input type="hidden" name="action" value="regist">
									<label>编号：</label>
									<input class="itxt" type="text" 
										   name="ISBN" value="<%=ISBN%>"
										   autocomplete="off" tabindex="1" name="username" id="username" />
									<br />
									<br />
									<label>书名：</label>
									<input class="itxt" type="text" name="bookName" value="<%=bookName%>"
										   autocomplete="off" tabindex="1" name="password" id="password" />
									<br />
									<br />
									<label>价格：</label>
									<input class="itxt" type="text" name="price" value="<%=price%>"
										   autocomplete="off" tabindex="1" name="repwd" id="repwd" />
									<br />
									<br />
									<label>出版社：</label>
									<input class="itxt" type="text" 
										   name="press" value="<%=press%>"
										   autocomplete="off" tabindex="1" name="email" id="email" />
									<br />
									<br />
									<label>作者：</label>
									<input class="itxt" type="text" 
										   name="author" value="<%=author%>"
										   autocomplete="off" tabindex="1" name="email" id="code" />
									<br />
									<br />
									<input type="submit" value="提交" id="sub_btn" />
								</form>
							</div>

						</div>
					</div>
				</div>
			</div>

		<%--静态包含页脚内容--%>
		<%@include file="/pages/common/footer.jsp"%>
</body>
</html>